#pragma once

#include "MathCommon.h"
#include "Vec3.h"

#include <cstdint>

#include "Color.m.h"

RSTRUCT()
struct WHENGINE_API SColor
{
    ROBJECT

    RFIELD()
    float R=1;

    RFIELD()
    float G=1;

    RFIELD()
    float B=1;

    RFIELD()
    float A=1;
    
    SColor(){};

    static SColor None;
    static SColor Black;
    static SColor Green;
    static SColor HalfGreen; //0x007F00
    static SColor Red;
    static SColor Blue;
    static SColor Yellow;
    static SColor White;

    SColor(float InR,float InG,float InB,float InA=1.0f)
    :R(InR),G(InG),B(InB),A(InA)
    {};

    RFUNCTION(ScriptConstructor)
    void ScriptConstruct(float InR,float InG,float InB,float InA=1.0f)
    {
        R=InR;
        G=InG;
        B=InB;
        A=InA;
    }

    static SColor FromHexRGB(uint32_t InHexRGB );

    CString ToHexString() const;

    SColor operator* (float Factor) const;

    SColor operator+ (const SColor& Other) const;

    SColor operator+= (const SColor& Other);

    SColor operator- (const SColor& Other) const;

    SColor operator-= (const SColor& Other);


    SColor(SVec3 RGB,float InA=1.0f)
    :R(RGB.X),G(RGB.Y),B(RGB.Z),A(InA)
    {};


    uint64_t GetHashCode() const;

    bool operator ==(const SColor& Other) const
    {
        return R==Other.R && G==Other.G && B==Other.B && A==Other.A;
    }

    SVec3 RGB()
    {
        return SVec3(R,G,B);
    }

    void ToFloatArray(float OutArray[4]) const;
};